#ifndef DYN_QUAD_H
#define DYN_QUAD_H

#include <armadillo>
#include <math.h>
#include <iostream>

#include "../utilities/dyn_functor.h"

using namespace std;

/*! \author Joey Dumont
 *
 * \date 2012-10-05
 *
 * \brief Abstract base class for all quadrature algorithsms.
 *
 * We provide a class to provide basic functionality
 * to the quadrature algorithms. Error control is
 * not assumed, but is implemented in most algorithms.
 * The algorithms are mostly inspired from the
 * Numerical Recipes ones.
 */
class Quad
{
public:
    /*! The constructor defines the function to be integrated,
     * the lower and upper bounds. The last (optional) argument
     * sets the accuracy we want to achieve.
     */
    Quad(Functor &_func,
         double _a,
         double _b,
         double _tol=1.0e-10);

    /*! Virtual destructor. */
    virtual ~Quad(){}

    /*! @name Accessor Functions */
    //@{
    virtual Functor& getFunctor(){return func;}
    virtual double getA(){return a;}
    virtual double getB(){return b;}
    virtual double getTol(){return tol;}

    virtual void setFunctor(Functor& _func){func=_func;}
    virtual void setA(double _a){a=_a;}
    virtual void setB(double _b){b=_b;}
    virtual void setTol(double _tol){tol=_tol;}
    //@}

    /*! Perform the quadrature. */
    virtual double doQuadrature() = 0;

protected:
    /*! @name Class Data */
    //@{
    Functor &func;
    double a;
    double b;
    double tol;
    //@}
};

#endif // DYN_QUAD_H
